﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Praxis.Entities;
using System.Data;

namespace Praxis.Repository
{
    public class EntregaDAO:MasterRepository, IEntregaDAO
    {
        public List<ENTREGA> GetAllEntregas()
        {
            var query = from c in Context.ENTREGAs
                        select c;
            return query.ToList();
        }

        public List<ENTREGA> GetFromEntregabyCriterio(string criterio)
        {
            throw new NotImplementedException();
        }

        public ENTREGA GetFromEntregaById(int id)
        {
            throw new NotImplementedException();
        }

        public void AddEntrega(ENTREGA entrega)
        {

            foreach (var item in entrega.DETALLE_ENTREGA)
            {
                //Context.Entry(item).State = EntityState.Unchanged;
                Context.Entry(item).State = EntityState.Added;
            }

            Context.Entry(entrega).State = EntityState.Unchanged;



            Context.ENTREGAs.Add(entrega);
            Context.SaveChanges();
        }

        public void UpdateEntrega(ENTREGA entrega)
        {
            throw new NotImplementedException();
        }

        public void RemoveEntrega(int id)
        {
            throw new NotImplementedException();
        }
    }
}
